<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="Annotation.DataBase.*"%>
<%@ page import="java.sql.*"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'createTeacherAcc' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
 
  <body>
    	<div align="center"> 
    		Create Account for Teacher 
    		<form name="createAccForm" id="createAccForm" method="post" action="createTeacherAccSignalSql.jsp">
	    		<table border="0" width="50%">
	    		
	    		
	    			<tr>
	    				<td width="40%" align="left">School</td>
	    				<td width="60%" align="center">
	    				<select id="selectSchool" name="selectSchool">
	    					<%--
	    					MySQLCommand ss= new MySQLCommand();
							String sql="select school from school ";
							ResultSet rs = ss.selectSQL(sql);
							while(rs.next()) 
							{ 
								String school=rs.getString("school"); 
								System.out.println(school);
							--%> 
								
							<%-- 
							<option value="<%=school%>" selected><%=school%></option> 
							
							} 
							--%> 
							
							<%
								  MySQLCommand ss= new MySQLCommand();
								  String sql="select school from school ";
								  ResultSet rs = ss.selectSQL(sql);
								  while(rs.next()){
									  String rm=rs.getString("school");
									  //System.out.println("From DB:"+rm);
								  	  out.println("<option value='"+rm+"'>"+rm+"</option>");
								  }
							%>
	    					
	    				</select>
	    				</td>
	    			</tr>  			
	    			
	    			<tr>
	    				<td width="40%" align="left">Teacher name</td>
	    				<td width="60%" align="center">
	    					<input type="text" id="teachername" name="teachername" width="100%" /> 
	    				</td>
	    			</tr>
	    			
	    			<tr>
	    				<td width="40%" align="left">Teacher number</td>
	    				<td width="60%" align="center">
	    					<input type="text" id="teachernumber" name="teachernumber" width="100%" /> 
	    				</td>
	    			</tr>
	    			
	    			<tr>
	    				<td width="40%" align="left">Login PWD</td>
	    				<td width="60%" align="center">
	    					<input type="password" id="pwd" name="pwd" width="100%" /> 
	    				</td>
	    			</tr>
	    			<tr>
	    				<td width="40%" align="left">Login PWD(again)</td>
	    				<td width="60%" align="center">
	    					<input type="password" id="pwdchk" name="pwdchk" width="100%" /> 
	    				</td>
	    			</tr>
	    			
	    			<tr>
	    				<td width="40%" align="left">Gender</td>
	    				<td width="60%" align="center">
	    					<input type="radio" name="gender" value="1" checked="checked" >Male</input>
							<input type="radio" name="gender" value="0" >Female</input>
	    				</td>
	    			</tr>
	    			    
	    			<tr>
	    				<td colspan="2" align="center">	    					
	    					<font color="red">
		    					<div id="alertlabel" style="display:none">
		    					</div>
	    					</font>
	    					
	    				</td>
	    			</tr>
	    			<tr>
	    				<td colspan="2" align="center">
	    					<input type="button" onClick="check()" value="CREATE" />
	    				</td>
	    			</tr>		
	    		</table>
    		</form>
    	</div>
    	
    	<script type="text/javascript">
    		function check(){
    			var pwd = document.getElementById("pwd").value;
    			var pwdchk = document.getElementById("pwdchk").value;
    			//判斷密碼跟檢查是不是空的
    			
    			if(pwd == "" || pwdchk == ""){
    				document.getElementById("alertlabel").innerHTML = "Password cannot empty!";
    				document.getElementById("alertlabel").style.display = "";
    				return;
    			}
    			
    			//檢查兩次
    			if(pwd != pwdchk){
    				document.getElementById("alertlabel").innerHTML = "Password check incorrect!";
    				document.getElementById("alertlabel").style.display = "";
    			}else{
    				document.getElementById("alertlabel").style.display = "none";
    				document.getElementById("createAccForm").submit();
    			}  
    					
    		}    	
    	</script>
  </body>
</html>
